package com.ruoyi.yey.parent.student;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.yey.student.StudentEntity;

import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ParentStudentService extends ServiceImpl<ParentStudentMapper,ParentStudentEntity> {

    public List<StudentEntity> getParentStudent(int parentId) {
        //根据parent_id获取学生信息
        return baseMapper.selectStudentByParent(parentId);
    }

    public void delByParentId(int parentId) {
        baseMapper.delete(Wrappers.<ParentStudentEntity>query().eq("parent_id",parentId));
    }

    public ParentStudentEntity findOne(int parentId,int studentId){
        return baseMapper.selectOne(
                new QueryWrapper<ParentStudentEntity>().eq("parent_id",parentId)
        .eq("student_id",studentId));
    }

}
